#include <cereal/types/unordered_map.hpp>
#include <cereal/types/memory.hpp>
#include <cereal/archives/binary.hpp>
#include <cereal/archives/json.hpp>
#include <fstream>

struct MyRecord
{
  uint8_t x, y;
  float z;

  template <class Archive>
  void serialize(Archive &ar)
  {
    ar(x, y, z);
  }
};

struct SomeData
{
  int32_t id;
  std::shared_ptr<std::unordered_map<uint32_t, MyRecord>> data;

  template <class Archive>
  void save(Archive &ar) const
  {
    ar(data);
  }

  template <class Archive>
  void load(Archive &ar)
  {
    static int32_t idGen = 0;
    id = idGen++;
    ar(data);
  }
};

int main()
{
  std::ofstream os("out.cereal", std::ios::binary);
  cereal::BinaryOutputArchive archive(os);

  MyRecord mr;
  mr.x = 1;
  mr.y = 2;
  mr.z = 3;
  SomeData myData;
  myData.data = std::shared_ptr<std::unordered_map<uint32_t, MyRecord>>(new std::unordered_map<uint32_t, MyRecord>);
  myData.data->insert(std::make_pair(4, mr));
  myData.id = 5;
  archive(myData);

  std::ofstream os1("out.json");
  cereal::JSONOutputArchive ar(os1);
  ar(myData);

  return 0;
}